package com.itzhihao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itzhihao.entity.Product;
import com.itzhihao.entity.vo.ProductVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface ProductMapper extends BaseMapper<Product> {

    /**
     * 查询商品详情
     * @param id
     * @return
     */
    @Select("select p.prod_id as id,s.store_id as storeId, s.store_time as storeTime,s.name as storeName,s.subImages as storeSubImages,s.mainImage as storeMainImage,s.notice as storeNotice," +
            "s.longitude as storeLongitude,s.latitude as storeLatitude,s.pos_name as storePosName,s.pos_address as storePosAddress,p.cate,p.prod_desc as prodDesc," +
            "p.name,p.mainimage as mainImage,p.subimages as subImages,p.sort,p.price,p.stock,p.discount,p.status,p.create_time as createTime,p.update_time as updateTime," +
            "p.create_by as createBy,p.update_by as updateBy from glgl_store as s,glgl_product as p where #{id}=p.prod_id and p.store_id=s.store_id and p.is_deleted=#{isDeleted}" +
            " and p.status = #{status}")
    ProductVo getProductDetail(@Param(value = "id") Long id,@Param(value = "status")Integer status,@Param(value = "isDeleted")Integer isDeleted);
}
